home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qtableview.h.z / qtableview.h
Encoding:
C/C++ Source or Header  |  2001-04-12  |  7.5 KB  |  275 lines

  1. /**********************************************************************
  2. ** $Id: qt/src/widgets/qtableview.h   2.3.0   edited 2001-01-26 $
  3. **
  4. ** Definition of QTableView class
  5. **
  6. ** Created : 941115
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QTABLEVIEW_H
  39. #define QTABLEVIEW_H
  40.  
  41. #ifndef QT_H
  42. #include "qframe.h"
  43. #endif // QT_H
  44.  
  45. #ifndef QT_NO_TABLEVIEW
  46.  
  47. class QScrollBar;
  48. class QCornerSquare;
  49.  
  50.  
  51. class Q_EXPORT QTableView : public QFrame
  52. {
  53.     Q_OBJECT
  54. public:
  55.     virtual void setBackgroundColor( const QColor & );
  56.     virtual void setPalette( const QPalette & );
  57.     void    show();
  58.  
  59.     void    repaint( bool erase=TRUE );
  60.     void    repaint( int x, int y, int w, int h, bool erase=TRUE );
  61.     void    repaint( const QRect &, bool erase=TRUE );
  62.  
  63. protected:
  64.     QTableView( QWidget *parent=0, const char *name=0, WFlags f=0 );
  65.    ~QTableView();
  66.  
  67.     int        numRows()    const;
  68.     virtual void setNumRows( int );
  69.     int        numCols()    const;
  70.     virtual void setNumCols( int );
  71.  
  72.     int        topCell()    const;
  73.     virtual void setTopCell( int row );
  74.     int        leftCell()    const;
  75.     virtual void setLeftCell( int col );
  76.     virtual void setTopLeftCell( int row, int col );
  77.  
  78.     int        xOffset()    const;
  79.     virtual void setXOffset( int );
  80.     int        yOffset()    const;
  81.     virtual void setYOffset( int );
  82.     virtual void setOffset( int x, int y, bool updateScrBars = TRUE );
  83.  
  84.     virtual int cellWidth( int col );
  85.     virtual int cellHeight( int row );
  86.     int        cellWidth()    const;
  87.     int        cellHeight()    const;
  88.     virtual void setCellWidth( int );
  89.     virtual void setCellHeight( int );
  90.  
  91.     virtual int totalWidth();
  92.     virtual int totalHeight();
  93.  
  94.     uint    tableFlags()    const;
  95.     bool    testTableFlags( uint f ) const;
  96.     virtual void setTableFlags( uint f );
  97.     void    clearTableFlags( uint f = ~0 );
  98.  
  99.     bool    autoUpdate()     const;
  100.     virtual void setAutoUpdate( bool );
  101.  
  102.     void    updateCell( int row, int column, bool erase=TRUE );
  103.  
  104.     QRect    cellUpdateRect() const;
  105.     QRect    viewRect()     const;
  106.  
  107.     int        lastRowVisible() const;
  108.     int        lastColVisible() const;
  109.  
  110.     bool    rowIsVisible( int row ) const;
  111.     bool    colIsVisible( int col ) const;
  112.  
  113.     QScrollBar *verticalScrollBar() const;
  114.     QScrollBar *horizontalScrollBar() const;
  115.  
  116. private slots:
  117.     void    horSbValue( int );
  118.     void    horSbSliding( int );
  119.     void    horSbSlidingDone();
  120.     void    verSbValue( int );
  121.     void    verSbSliding( int );
  122.     void    verSbSlidingDone();
  123.  
  124. protected:
  125.     virtual void paintCell( QPainter *, int row, int col ) = 0;
  126.     virtual void setupPainter( QPainter * );
  127.  
  128.     void    paintEvent( QPaintEvent * );
  129.     void    resizeEvent( QResizeEvent * );
  130.  
  131.     int        findRow( int yPos ) const;
  132.     int        findCol( int xPos ) const;
  133.  
  134.     bool    rowYPos( int row, int *yPos ) const;
  135.     bool    colXPos( int col, int *xPos ) const;
  136.  
  137.     int        maxXOffset();
  138.     int        maxYOffset();
  139.     int        maxColOffset();
  140.     int        maxRowOffset();
  141.  
  142.     int        minViewX()    const;
  143.     int        minViewY()    const;
  144.     int        maxViewX()    const;
  145.     int        maxViewY()    const;
  146.     int        viewWidth()    const;
  147.     int        viewHeight()    const;
  148.  
  149.     void    scroll( int xPixels, int yPixels );
  150.     void    updateScrollBars();
  151.     void    updateTableSize();
  152.  
  153. private:
  154.     void    coverCornerSquare( bool );
  155.     void    snapToGrid( bool horizontal, bool vertical );
  156.     virtual void    setHorScrollBar( bool on, bool update = TRUE );
  157.     virtual void    setVerScrollBar( bool on, bool update = TRUE );
  158.     void    updateView();
  159.     int        findRawRow( int yPos, int *cellMaxY, int *cellMinY = 0,
  160.                 bool goOutsideView = FALSE ) const;
  161.     int        findRawCol( int xPos, int *cellMaxX, int *cellMinX = 0,
  162.                 bool goOutsideView = FALSE ) const;
  163.     int        maxColsVisible() const;
  164.  
  165.     void    updateScrollBars( uint );
  166.     void    updateFrameSize();
  167.  
  168.     void    doAutoScrollBars();
  169.     void    showOrHideScrollBars();
  170.  
  171.     int        nRows;
  172.     int        nCols;
  173.     int        xOffs, yOffs;
  174.     int        xCellOffs, yCellOffs;
  175.     short    xCellDelta, yCellDelta;
  176.     short    cellH, cellW;
  177.  
  178.     uint    eraseInPaint        : 1;
  179.     uint    verSliding        : 1;
  180.     uint    verSnappingOff        : 1;
  181.     uint    horSliding        : 1;
  182.     uint    horSnappingOff        : 1;
  183.     uint    coveringCornerSquare    : 1;
  184.     uint    sbDirty            : 8;
  185.     uint    inSbUpdate        : 1;
  186.  
  187.     uint    tFlags;
  188.     QRect    cellUpdateR;
  189.  
  190.     QScrollBar *vScrollBar;
  191.     QScrollBar *hScrollBar;
  192.     QCornerSquare *cornerSquare;
  193.  
  194. private:    // Disabled copy constructor and operator=
  195. #if defined(Q_DISABLE_COPY)
  196.     QTableView( const QTableView & );
  197.     QTableView &operator=( const QTableView & );
  198. #endif
  199. };
  200.  
  201.  
  202. const uint Tbl_vScrollBar    = 0x00000001;
  203. const uint Tbl_hScrollBar    = 0x00000002;
  204. const uint Tbl_autoVScrollBar    = 0x00000004;
  205. const uint Tbl_autoHScrollBar    = 0x00000008;
  206. const uint Tbl_autoScrollBars    = 0x0000000C;
  207.  
  208. const uint Tbl_clipCellPainting = 0x00000100;
  209. const uint Tbl_cutCellsV    = 0x00000200;
  210. const uint Tbl_cutCellsH    = 0x00000400;
  211. const uint Tbl_cutCells        = 0x00000600;
  212.  
  213. const uint Tbl_scrollLastHCell    = 0x00000800;
  214. const uint Tbl_scrollLastVCell    = 0x00001000;
  215. const uint Tbl_scrollLastCell    = 0x00001800;
  216.  
  217. const uint Tbl_smoothHScrolling = 0x00002000;
  218. const uint Tbl_smoothVScrolling = 0x00004000;
  219. const uint Tbl_smoothScrolling    = 0x00006000;
  220.  
  221. const uint Tbl_snapToHGrid    = 0x00008000;
  222. const uint Tbl_snapToVGrid    = 0x00010000;
  223. const uint Tbl_snapToGrid    = 0x00018000;
  224.  
  225.  
  226. inline int QTableView::numRows() const
  227. { return nRows; }
  228.  
  229. inline int QTableView::numCols() const
  230. { return nCols; }
  231.  
  232. inline int QTableView::topCell() const
  233. { return yCellOffs; }
  234.  
  235. inline int QTableView::leftCell() const
  236. { return xCellOffs; }
  237.  
  238. inline int QTableView::xOffset() const
  239. { return xOffs; }
  240.  
  241. inline int QTableView::yOffset() const
  242. { return yOffs; }
  243.  
  244. inline int QTableView::cellHeight() const
  245. { return cellH; }
  246.  
  247. inline int QTableView::cellWidth() const
  248. { return cellW; }
  249.  
  250. inline uint QTableView::tableFlags() const
  251. { return tFlags; }
  252.  
  253. inline bool QTableView::testTableFlags( uint f ) const
  254. { return (tFlags & f) != 0; }
  255.  
  256. inline QRect QTableView::cellUpdateRect() const
  257. { return cellUpdateR; }
  258.  
  259. inline bool QTableView::autoUpdate() const
  260. { return isUpdatesEnabled(); }
  261.  
  262. inline void QTableView::repaint( bool erase )
  263. { repaint( 0, 0, width(), height(), erase ); }
  264.  
  265. inline void QTableView::repaint( const QRect &r, bool erase )
  266. { repaint( r.x(), r.y(), r.width(), r.height(), erase ); }
  267.  
  268. inline void QTableView::updateScrollBars()
  269. { updateScrollBars( 0 ); }
  270.  
  271.  
  272. #endif // QT_NO_TABLEVIEW
  273.  
  274. #endif // QTABLEVIEW_H
  275.